import java.util.*;;
public class _12132 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        int t= sc.nextInt();
        for(int i=0;i<t;i++){
            String n = sc.next();
            System.out.println(fuck(n));
            int q=fuck(n);
            if(q==0){
                System.out.println("No");
            }else System.out.println("Yes");
        }
    }
    public static int fuck(String s){
        int n =s.length();
        System.out.println(s.substring(1, 2));
        String a="fuck";
        int id = s.indexOf(a);
        System.out.println("id="+id);
        System.out.println();
        Integer i =Integer.parseInt(s);
        if(n==1){
            return i;
        }
        double m = Math.pow(10, n-1);
        int end=(n-1)*9;
        end+=i/m;
        return end; 

    }
}
